import 'package:flutter/material.dart';
import 'package:transparent_image/transparent_image.dart';
main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {

    return Scaffold(
        appBar: AppBar(
            title: RaisedButton(
          child: Text("返回"),
          onPressed: () => Navigator.pop(context, "image result"),
        )),
        body: ListView(
          children: <Widget>[
            FadeInImage2(),
            TextDemo(),
            TextContainor(),
            ImageNet(),
            ImageStack(BoxFit.cover),
            ImageStack(BoxFit.fill),
            ImageStack(BoxFit.fitHeight),
            ImageStack(BoxFit.fitWidth),
            ImageStack(BoxFit.contain),
            ImageStack(BoxFit.none),
            ImageStack(BoxFit.scaleDown),
            ImageGroup(MainAxisSize.min),
            ImageGroup(MainAxisSize.max),
          ],
        )
        //          body: center
        );
  }
}
var url = "https://upload.jianshu.io/users/upload_avatars/2984407/59d2072a7dde.jpg";
class ImageNet extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Image(
        height: 40.0,
        fit: BoxFit.contain,
        image: NetworkImage(
            url,
            scale: 2.0));
  }
}

class TextContainor extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      padding: EdgeInsetsDirectional.fromSTEB(10.0, 10.0, 10.0, 10.0),
      alignment: Alignment.bottomCenter,
      child: Text(
        "hello imooc",
        style: TextStyle(fontSize: 40.0),
      ),
      margin: EdgeInsets.all(10),
      decoration: BoxDecoration(
          gradient: LinearGradient(colors: [Colors.red, Colors.blue])),
    );
  }
}


class TextDemo extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Text(
      "123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789",
      textAlign: TextAlign.left,
      maxLines: 3,
      overflow: TextOverflow.ellipsis,
      style: TextStyle(
        fontSize: 30.0,
        color: Colors.red,
        decoration: TextDecoration.lineThrough,
        decorationStyle: TextDecorationStyle.solid,
      ),
    );
  }
}

class FadeInImage2 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return  new Stack(
          children: <Widget>[
            new Center(child: new CircularProgressIndicator()),
            new Center(
              child:  FadeInImage.memoryNetwork(
                placeholder: kTransparentImage,
                image:url,
              ),
            ),
          ],
        );
  }}
class ImageGroup extends StatelessWidget {
  MainAxisSize mainAxisSize;
  ImageGroup(this.mainAxisSize,{Key key}):super(key:key);

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisSize: mainAxisSize,
      children: [
        new Icon(Icons.star, color: Colors.green[500]),
        new Icon(Icons.star, color: Colors.green[500]),
        new Icon(Icons.star, color: Colors.green[500]),
        new Icon(Icons.star, color: Colors.black),
        new Icon(Icons.star, color: Colors.black),
      ],
    );
  }
}

class ImageStack extends StatelessWidget {
  BoxFit fit;

  ImageStack(this.fit, {Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Stack(
        alignment: FractionalOffset(0.5, 0.9),
        overflow: Overflow.visible,
        children: [
          Image(
              fit: fit,
              width: 300.0,
              height: 200.0,
              image: AssetImage("images/aa.jpg")),
          Positioned(
            child: Text(
              " BoxFit $fit",
              style: TextStyle(
                fontSize: 20.0,
                color: Colors.black87,
              ),
            ),
          )
        ]);
  }
}
